package mil.af.amc.adpetracker.util;

import mil.af.amc.adpetracker.dao.AccountDao;
import mil.af.amc.adpetracker.model.Account;
import org.springframework.dao.DataAccessException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;

import java.util.List;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */

public class AccountJdbcDaoImpl extends JdbcDaoImpl {

    private AccountDao accountDao;


    public void setAccountDao(AccountDao accountDao) {
        this.accountDao = accountDao;
    }

    @Override
    protected List loadUsersByUsername(String string) {
        return super.loadUsersByUsername(string);
    }

    // Ouch. MAJOR hack job here, calling a hibernate DAO from what is supposed to be a JDBC DAO
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {

        Account acct = accountDao.getByUsername(username);
        
        return acct;
    }
}
